package com.duty.UI;

import com.duty.UI.R;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.Spinner;
import android.widget.AdapterView.OnItemSelectedListener;

public class SelectProvinceActivity extends Activity {	
		
	private String province;
	
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.province);

      //create the spinner to hold the list of Class events that can be added
		Spinner courseSpinner = (Spinner) findViewById(R.id.addCourseSpinner);
		ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this, R.array.ProvinceActivityArray, android.R.layout.simple_spinner_item);
		adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
		courseSpinner.setAdapter(adapter);
    
		// Set up a call back for the spinner
		courseSpinner.setOnItemSelectedListener(new OnItemSelectedListener() {
			public void onNothingSelected(AdapterView<?> arg0) {
				// Do nothing.
			}

			public void onItemSelected(AdapterView<?> parent, View v, int position, long id) {
				final Spinner selectedEvent = (Spinner) findViewById(R.id.addCourseSpinner);
				province = selectedEvent.getSelectedItem().toString();
				
				if (province.equals("Alberta") ) {		
	        		Intent viewProvince = new Intent(SelectProvinceActivity.this, ImportTypeActivity.class);
	        		viewProvince.putExtra("province", province);
	        		startActivity(viewProvince);
		        }
				else if (province.equals("British Columbia") ) {
		        	Intent viewProvince = new Intent(SelectProvinceActivity.this, ImportTypeActivity.class);
		        	viewProvince.putExtra("province", province);
		        	startActivity(viewProvince);
		        }
		        else if (province.equals("Manitoba") ) {
		        	Intent viewProvince = new Intent(SelectProvinceActivity.this, ImportTypeActivity.class);
		        	viewProvince.putExtra("province", province);
		        	startActivity(viewProvince);
		        }
		        else if (province.equals("New Brunswick") ) {
		        	Intent viewProvince = new Intent(SelectProvinceActivity.this, ImportTypeActivity.class);
		        	viewProvince.putExtra("province", province);
		        	startActivity(viewProvince);
		        }
		        else if (province.equals("Newfoundland") ) {
		        	Intent viewProvince = new Intent(SelectProvinceActivity.this, ImportTypeActivity.class);
		        	viewProvince.putExtra("province", province);
		        	startActivity(viewProvince);
		        }
		        else if (province.equals("Nova Scotia") ) {
		        	Intent viewProvince = new Intent(SelectProvinceActivity.this, ImportTypeActivity.class);
		        	viewProvince.putExtra("province", province);
		        	startActivity(viewProvince);
		        }
		        else if (province.equals("Ontario") ) {
		        	Intent viewProvince = new Intent(SelectProvinceActivity.this, ImportTypeActivity.class);
		        	viewProvince.putExtra("province", province);
		        	startActivity(viewProvince);
		        }
		        else if (province.equals("P.E.I.") ) {
		        	Intent viewProvince = new Intent(SelectProvinceActivity.this, ImportTypeActivity.class);
		        	viewProvince.putExtra("province", province);
		        	startActivity(viewProvince);
		        }
		        else if (province.equals("Quebec") ) {
		        	Intent viewProvince = new Intent(SelectProvinceActivity.this, ImportTypeActivity.class);
		        	viewProvince.putExtra("province", province);
		        	startActivity(viewProvince);
		        }
		        else if (province.equals("Saskatchewan") ) {
		        	Intent viewProvince = new Intent(SelectProvinceActivity.this, ImportTypeActivity.class);
		        	viewProvince.putExtra("province", province);
		        	startActivity(viewProvince);
		        }
		        else if (province.equals("N.W.T.") ) {
		        	Intent viewProvince = new Intent(SelectProvinceActivity.this, NunavutNWT.class);
		        	startActivity(viewProvince);
		        }
		        else if (province.equals("Nunavut") ) {
		        	Intent viewProvince = new Intent(SelectProvinceActivity.this, NunavutNWT.class);
		        	startActivity(viewProvince);
		        }
		        else if (province.equals("Yukon") ) {
		        	Intent viewProvince = new Intent(SelectProvinceActivity.this, ImportTypeActivity.class);
		        	viewProvince.putExtra("province", province);
		        	startActivity(viewProvince);
		        }
				
				
			} //end onItemSelected

		});
        
    }           
}      
    
    
    
